/*******************************************OVERVIEW*******************************************************
 
 Political Fear and Loathing on Wall Street
 
 Replication do file
 
Figure 2: P/L of Long Variance Swap Contracts around Elections, 2012-2020
 
 Version July 9 2023 
 
  
********************************************************************************************************************/

clear
set more off
#delimit ;


/*Set Directory -- You will need to adjust this line of code accordingly */; 


cd "/Users/ssaiegh/Files/Mac/VIX/VIX/";

/*Create Log File*/;

log using "Figure 2", replace text;


/*Load Data File*/;

use "election_risk.dta";

/*Declare Time Series*/;


tsset case;


/*Estimate Variance Swap Contract Payoff (Appendix B)*/;

gen srd_ret=(log(close/L.close))^2;

tssmooth ma ma_sq_ret= srd_ret, window(0 0 7);
gen sum_ma=ma_sq_ret*7;


gen rvs=sqrt((252*sum_ma)/7)*100;

gen difference=rvs^2-vix9d^2;

gen vn=100/(2*vix9d);

gen swap_vega_payment=(difference*vn)/100;

/*Generate Figure 2*/;


collapse swap_vega_payment if order>-14 & order<8, by(order);

tsset order;


tsline swap_vega_payment;



log c;
